import scala.io.StdIn
import scala.util.control.Breaks._

object exercise001 {
  def main(args: Array[String]): Unit = {
    var uname = ""
    var pw = ""
    breakable(
      for (i <- 1 to 3) {
        println("请输入账号:")
        var uname = StdIn.readLine()
        println("请输入密码:")
        var pw = StdIn.readLine()
        if (uname == "itcast"  && pw == "1234") {
          println("登录成功！")
          break()
        } else {
          if(i==3){
            println("账号密码错误超过登陆次数！")
          }else{
            println("账号或密码错误！你还有" + (3 - i) + "次机会")
          }
        }
      }
    )
  }
}
